<template>
	<div >
		
		<el-tabs v-model="activeName" :stretch="flag" type="border-card" @tab-click="handleClick" >
			<el-tab-pane label="员工列表" name="first"><div Style="margin: 0 auto; width: 70%; height: 750px;"><staffInfo></staffInfo></div></el-tab-pane>
			<el-tab-pane label="信息总览" name="four"><div Style="margin: 0 auto; width: 70%; height: 750px;"><staffBrower :mathe="mathe" :mathe1="mathe1"></staffBrower></div></el-tab-pane>
		</el-tabs>
	</div>
</template>

<script>
		// import mealInfo from '@/components/meal_info/Meal_info.vue'
		import staffInfo from '@/components/staff_info/Staff_info.vue'
		import staffBrower from "@/components/fold_line/staff_browse.vue"
		import {
			request
		} from "network/request.js"
	export default {
		name: 'Staff_main',
	data: function() {
		return {
			activeName: 'first',
			flag:true,
			mathe:0,//员工出勤率
			mathe1:0//员工忙绿比例
		}
	},
	methods: {
		handleClick(tab, event) {
			let count0=0;
			let count1=0;
			let count2=0;
			let count=0;
				 if(tab.name=='four'){
					 request({
					 	url: '/Emp/empInfos',
					 	method: 'get'
					 }).then(res => {
					 	// console.log(res.data)
					 
					 	if (res.data.length > 0) {
							res.data=res.data.filter(item => item.empstate!='3')
							
					 		res.data.forEach(s => {
					 			/*********empstate************/
					 			if (s.empstate == '0') {
					 				s.empstate = "休假"
									count0=count0+1;
					 			} else if (s.empstate == '1') {
					 				s.empstate = "忙碌"
									count1=count1+1;
					 			} else {
					 				s.empstate = "就绪"
									count2=count2+1
					 			}
					 		})
							count=res.data.length;
					 	}
					this.mathe=Math.round(((count1+count2)/count)*100)
					this.mathe1=Math.round((count1/(count1+count2))*100)
					// console.log(this.mathe)
					// console.log(this.mathe1)
					 })
				 }
		}
	},
	components:{
		staffInfo,
		staffBrower
	}
	}
</script>

<style>
</style>
